/*
 * Copyright (c) 2018. czmc All Rights Reserved.
 * Author: czmc
 * Email: zxc6355533@163.com
 * Encoding: UTF-8
 */

package top.stime21.myneighbours.base

import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import top.stime21.framework.mvp.MvpContract
import top.stime21.framework.mvp.MvpPresenter


/**
 * Author: czmc  Email: zxc6355533@163.com
 * Version:	1.0  Date:2018/3/1
 */
abstract class MvpBasePrensenter<V : MvpContract.View, M : MvpContract.Model> : MvpPresenter<V, M>() {
    private  var compositeDisposable: CompositeDisposable? = null

    fun addSubscription(disposable: Disposable) {
        if (compositeDisposable == null) {
            compositeDisposable = CompositeDisposable()
        }
        compositeDisposable!!.add(disposable)
    }

    fun unSubscription() {
        if (compositeDisposable != null) {
            compositeDisposable!!.clear()
        }
    }
    override fun onViewDestory() {
        unSubscription()
    }


}